#include"Convert2D3D.h"
#include"Game.h"
/////////////////
//include
/////////////////
#include<ANX\ContentManager.h>
#include<ANX\Key.h>
/////////////////
//prottype
/////////////////

/////////////////
//const
/////////////////
const std::string name = "Resource/";

Convert2D3D::Convert2D3D()
{
}
Convert2D3D::~Convert2D3D()
{
}
void Convert2D3D::Init() 
{

}
void Convert2D3D::ContentLoad(Device* device) 
{
	effect = ContentManager::LoadAnime(name+"Dead.png",5,1);
	Game::camera.SetPos(Vector3D(0,0,300));
	Game::camera.SetLook(Vector3D(0,0,-300));
	player = ContentManager::LoadModel("Resource/Knuckle/","Knuckle.pmd");
}
void Convert2D3D::Update() 
{
	
	float speed = 2.0f;
	if(Key::IsPushing(VK_RIGHT))
	{
		player_pos.x+= speed;
	}
	if(Key::IsPushing(VK_LEFT))
	{
		player_pos.x-= speed;
	}
	if(Key::IsPushing(VK_UP))
	{
		player_pos.y+= speed;
	}
	if(Key::IsPushing(VK_DOWN))
	{
		player_pos.y-= speed;
	}
}
void Convert2D3D::Draw(DeviceContext* device_context)
{
	Game::sprite_drawer-> Begin();
	
	Matrix tmp_perspective	 = Game::camera.GetPerspectiveMatrix();
	Matrix tmp_camera_matrix =  Game::camera.GetCameraMatrix();

	Vector3D tmp_pos		 =  player_pos *(tmp_camera_matrix * tmp_perspective);
	Vector2D pos			 = tmp_pos.GetScreenPos(&Game::camera);
	Vector3D tex_size = effect->GetAnimationSize();
//	Game::sprite_drawer->DrawAnimation(effect,pos.x - tex_size.x/2,pos.y - tex_size.y/2);
	Game::sprite_drawer-> End();
	player->SetPos(player_pos);
	player->Draw(device_context);
	effect->Loop();
}